import request from '@/utils/request'


// 查询列表
export function querylist(query) {
    return request({
        url: '/user/page',
        method: 'get',
        params: query
    })
}

//获取所有角色列表
export function getRoleList(userId) {
    return request({
        url: '/user/getRoleList/' + userId,
        method: 'get'
    })
}

export function saveOrUpdateUser(data) {
    return request({
        url: '/user/saveOrUpdate',
        method: 'post',
        data
    })
}


/**
 *
 * @param {根据主键查询用户} id
 * @returns
 */
export function getById(id) {
    return request({
        url: '/user/get/' + id,
        method: 'get'
    })
}

/**
 *
 * @param {根据主键查询用户} id
 * @returns
 */
export function removeById(id) {
    return request({
        url: '/user/' + id,
        method: 'delete'
    })
}

export function grant(userId, roleIds) {

    return request({
        url: '/user/grant',
        method: 'post',
        data: {
            userId: userId,
            roleIds: roleIds
        }
    })
}

export function getUserInfo() {
    return request({
        url: '/user/info',
        method: 'get'
    })
}